package com.qt.thread.scxf;

/**
 * @Author zsf
 * @Date 2023/10/3 14:50
 * @Version 1.0
 */
public class Cooker extends  Thread {
    public Cooker() {
    }

    public Cooker(String name) {
        super(name);
    }

    @Override
    public void run() {

        while (true){

            synchronized (Desk.lock) {
                if(Desk.foodCount == 0){
                    break;
                }else {

                    if(!Desk.flag){
                        Desk.flag = true;
                        System.out.println(Thread.currentThread().getName()+" 正在炒菜");
                        Desk.lock.notifyAll();
                    }else {
                        try {
                            Desk.lock.wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }


        }


    }
}
